package com.dotflat.survey.domain;

import com.dotflat.rest.domain.AreableObjectBase;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

@Entity
@Table(name = "dw_survey_sheet")
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel("问卷")
public class SurveySheet extends AreableObjectBase {

    @Column(columnDefinition = "varchar(32)  COMMENT '标题'", nullable = false)
    @ApiModelProperty("标题")
    private String title;

    @Column(columnDefinition = "datetime DEFAULT NOW() COMMENT '有效期' ")
    @ApiModelProperty("有效期")
    private Date validTo = new Date();

    @Column(columnDefinition = "varchar(32)  COMMENT '幼儿园名称'", nullable = false)
    @ApiModelProperty("幼儿园名称")
    private String areaName;

    @Column(columnDefinition = "varchar(32)  COMMENT '老师名称'", nullable = false)
    @ApiModelProperty("老师名称")
    private String staffName;

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "sheet")
    @OrderBy("seq desc")
    @ApiModelProperty("条目列表")
    private List<SurveySheetItem> items;

}
